import request from '@/utils/request'

/**
 * 获取班级列表
 * @param {number} examId - 考试ID
 */
export function getClassList(examId) {
  return request({
    url: '/api/class/list',
    method: 'get',
    params: { examId }
  })
}

/**
 * 获取班级详情
 * @param {number} id - 班级ID
 */
export function getClassDetail(id) {
  return request({
    url: `/api/class/${id}`,
    method: 'get'
  }).then(handleResponse)
}

// 统一处理响应
const handleResponse = (response) => {
  if (response.code !== 200) {
    throw new Error(response.message || '获取数据失败')
  }
  return response
} 